var api = require('../../assets/js/api.js');
Page({
    data: {
        bannerSwiperConfig: getApp().globalData.bannerSwiperConfig,
        caseList: [
            {
                img: "/images/case1.png",
                title: "母婴"
            },
            {
              img: "/images/case2.png",
                title: "服饰"
            },
            {
              img: "/images/case3.png",
              title: "运动"
            },
            {
              img: "/images/case4.png",
              title: "汽车"
            },
            {
              img: "/images/case5.png",
              title: "餐饮"
            }
        ]
    },
    onLoad: function () {
        getApp().getBannerList(this);
        //this.getCaseList();
    },
    getCaseList: function () {
        var $this = this;
        wx.showLoading({
            title: "加载中",
            mask: true,
            success: function () {
                wx.request({
                    url: api.apiPath.getCaseList,
                    data: {
                        page: 1,
                        size: 5
                    },
                    method: 'GET',
                    success: function (res) {
                        var success = res.data.success,
                            list = res.data.root;
                        if (success) {
                            var arr = [];
                            for (var i = 0, len = list.length; i < len; i++) {
                                var item = list[i];
                                arr.push({
                                    img: api.getImgFullPath(item['image']),
                                    title: item['innerTitle']
                                });
                            }
                            $this.setData({
                                "caseList": arr
                            });
                        }
                    },
                    fail: function (res) {
                        console.error("get case list error!");
                    },
                    complete: function() {
                        wx.hideLoading();
                    }
                });
            }
        });
    }
});